import logging
from conf import Config

class IgnoreList():
    ignorelist = []

    def reload(self):
        self.clearList()
        for i in str(Config.blacklist).split():
            self.addToList(i)

    def load(self):
        for i in str(Config.blacklist).split():
            self.addToList(i)

    def addToList(self, IP):
        self.ignorelist.append(IP)
        logging.info('Added ' + IP + ' to ignore list.')
        
    def clearList(self):
        self.ignorelist = []
        logging.info('Ignore list was cleared.')
        
    def remove(self, IP):
        self.ignorelist.remove(IP)
        logging.info('Removed ' + IP + ' from ignore list.')
        
    def checkIP(self, IP):
        for i in self.ignorelist:
            if i == IP:
                return True
        return False